#include <iostream>

#define MaxSize 50
//typedef struct {
//    ElemType data[MaxSize];
//    int len;
//} SqList;
//插入的步骤
/*
 * 1.判断插入位置i是否合法(满足1<=i<=len+1)
 * 2.判断存储空间是否已满(即插入x后是否会超出数组长度)
 * */
int main() {
//    std::cout << "Hello, World!" << std::endl;
    int num, i, j, len = 0;
    int a[10] = {1, 2, 3, 4, 5, 7, 8, 9, 10};
    len = 8;
    scanf("%d", &num);
    //若大于数组最后一个元素的值
    if (num > a[len]) {
        a[len + 1] = num;
        len++;
    } else {
    //若小于等于前面的值
        len++;//线性表长度+1
        for (i = 0; i < len; i++) {
            if (num < a[i]) {
                for (j = len - 1; j >= i; j--) {
                    //将最后一个元素到第i个元素依次后移一位
                    a[j + 1] = a[j];
                }
                a[i] = num;//讲小于num的a[i]原来的值覆盖掉
                break;
            }
        }
    }
    for (i = 0; i <= len; i++) {
        printf("%d ", a[i]);
    }

    return 0;
}
